In [1]:
# ATMS 305 - FALL 2024 - Lab02_Franklin
# Grading rubrics: C (20), D/E (15 each), F (50)
# Assignments without .html *and* .ipynb will not be graded!
In [2]:
# >>> A. PYTHON IMPORT
#  Import the usual suspects: pyplot and image
#  ... add to this: numpy as np (Numerical Python)
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
In [3]:
# >>> B. GET and READ IN IMAGES
# Get (wget) the 4 .png images at: rfd.atmos.uiuc.edu/305/Hurr_Franklin
#    You'll need: infrared, geocolor, vapor and CO2.
!wget -O infrared.png http://rfd.atmos.uiuc.edu/305/Hurr_Franklin/IR.png
!wget -O geocolor.png http://rfd.atmos.uiuc.edu/305/Hurr_Franklin/GEO.png
!wget -O vapor.png http://rfd.atmos.uiuc.edu/305/Hurr_Franklin/WV.png
!wget -O CO2.png http://rfd.atmos.uiuc.edu/305/Hurr_Franklin/CO2.png
--2024-09-12 10:19:11--  http://rfd.atmos.uiuc.edu/305/Hurr_Franklin/IR.png
Resolving rfd.atmos.uiuc.edu (rfd.atmos.uiuc.edu)... 192.17.107.225
Connecting to rfd.atmos.uiuc.edu (rfd.atmos.uiuc.edu)|192.17.107.225|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1895265 (1.8M) [image/png]
Saving to: 'infrared.png'

     0K .......... .......... .......... .......... ..........  2%  831K 2s
    50K .......... .......... .......... .......... ..........  5% 3.52M 1s
   100K .......... .......... .......... .......... ..........  8% 3.91M 1s
   150K .......... .......... .......... .......... .......... 10% 7.02M 1s
   200K .......... .......... .......... .......... .......... 13% 6.47M 1s
   250K .......... .......... .......... .......... .......... 16% 13.9M 1s
   300K .......... .......... .......... .......... .......... 18% 5.86M 0s
   350K .......... .......... .......... .......... .......... 21% 6.79M 0s
   400K .......... .......... .......... .......... .......... 24% 14.1M 0s
   450K .......... .......... .......... .......... .......... 27% 11.8M 0s
   500K .......... .......... .......... .......... .......... 29% 24.6M 0s
   550K .......... .......... .......... .......... .......... 32% 6.32M 0s
   600K .......... .......... .......... .......... .......... 35% 23.3M 0s
   650K .......... .......... .......... .......... .......... 37% 11.2M 0s
   700K .......... .......... .......... .......... .......... 40% 13.3M 0s
   750K .......... .......... .......... .......... .......... 43% 25.7M 0s
   800K .......... .......... .......... .......... .......... 45% 14.2M 0s
   850K .......... .......... .......... .......... .......... 48% 8.56M 0s
   900K .......... .......... .......... .......... .......... 51% 42.6M 0s
   950K .......... .......... .......... .......... .......... 54% 10.9M 0s
  1000K .......... .......... .......... .......... .......... 56% 13.8M 0s
  1050K .......... .......... .......... .......... .......... 59% 21.5M 0s
  1100K .......... .......... .......... .......... .......... 62% 17.7M 0s
  1150K .......... .......... .......... .......... .......... 64%  141M 0s
  1200K .......... .......... .......... .......... .......... 67% 5.46M 0s
  1250K .......... .......... .......... .......... .......... 70%  418M 0s
  1300K .......... .......... .......... .......... .......... 72% 31.4M 0s
  1350K .......... .......... .......... .......... .......... 75% 45.5M 0s
  1400K .......... .......... .......... .......... .......... 78% 12.2M 0s
  1450K .......... .......... .......... .......... .......... 81% 9.05M 0s
  1500K .......... .......... .......... .......... .......... 83%  632M 0s
  1550K .......... .......... .......... .......... .......... 86% 16.5M 0s
  1600K .......... .......... .......... .......... .......... 89% 41.5M 0s
  1650K .......... .......... .......... .......... .......... 91% 39.5M 0s
  1700K .......... .......... .......... .......... .......... 94% 18.3M 0s
  1750K .......... .......... .......... .......... .......... 97% 42.2M 0s
  1800K .......... .......... .......... .......... .......... 99% 14.9M 0s
  1850K                                                       100% 16.1G=0.2s

2024-09-12 10:19:12 (8.74 MB/s) - 'infrared.png' saved [1895265/1895265]

--2024-09-12 10:19:12--  http://rfd.atmos.uiuc.edu/305/Hurr_Franklin/GEO.png
Resolving rfd.atmos.uiuc.edu (rfd.atmos.uiuc.edu)... 192.17.107.225
Connecting to rfd.atmos.uiuc.edu (rfd.atmos.uiuc.edu)|192.17.107.225|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2206382 (2.1M) [image/png]
Saving to: 'geocolor.png'

     0K .......... .......... .......... .......... ..........  2%  791K 3s
    50K .......... .......... .......... .......... ..........  4% 1.89M 2s
   100K .......... .......... .......... .......... ..........  6% 9.06M 1s
   150K .......... .......... .......... .......... ..........  9% 8.44M 1s
   200K .......... .......... .......... .......... .......... 11% 3.24M 1s
   250K .......... .......... .......... .......... .......... 13% 10.8M 1s
   300K .......... .......... .......... .......... .......... 16% 10.6M 1s
   350K .......... .......... .......... .......... .......... 18% 3.08M 1s
   400K .......... .......... .......... .......... .......... 20% 21.9M 1s
   450K .......... .......... .......... .......... .......... 23% 24.9M 0s
   500K .......... .......... .......... .......... .......... 25% 5.78M 0s
   550K .......... .......... .......... .......... .......... 27% 4.78M 0s
   600K .......... .......... .......... .......... .......... 30% 48.0M 0s
   650K .......... .......... .......... .......... .......... 32% 16.4M 0s
   700K .......... .......... .......... .......... .......... 34% 14.0M 0s
   750K .......... .......... .......... .......... .......... 37% 7.87M 0s
   800K .......... .......... .......... .......... .......... 39% 7.81M 0s
   850K .......... .......... .......... .......... .......... 41% 10.0M 0s
   900K .......... .......... .......... .......... .......... 44% 42.9M 0s
   950K .......... .......... .......... .......... .......... 46% 19.7M 0s
  1000K .......... .......... .......... .......... .......... 48% 23.8M 0s
  1050K .......... .......... .......... .......... .......... 51% 14.9M 0s
  1100K .......... .......... .......... .......... .......... 53% 5.71M 0s
  1150K .......... .......... .......... .......... .......... 55% 23.3M 0s
  1200K .......... .......... .......... .......... .......... 58% 10.5M 0s
  1250K .......... .......... .......... .......... .......... 60% 32.3M 0s
  1300K .......... .......... .......... .......... .......... 62% 42.8M 0s
  1350K .......... .......... .......... .......... .......... 64% 16.4M 0s
  1400K .......... .......... .......... .......... .......... 67% 24.5M 0s
  1450K .......... .......... .......... .......... .......... 69% 31.2M 0s
  1500K .......... .......... .......... .......... .......... 71% 9.77M 0s
  1550K .......... .......... .......... .......... .......... 74% 10.0M 0s
  1600K .......... .......... .......... .......... .......... 76% 10.7M 0s
  1650K .......... .......... .......... .......... .......... 78% 33.3M 0s
  1700K .......... .......... .......... .......... .......... 81% 37.7M 0s
  1750K .......... .......... .......... .......... .......... 83% 49.7M 0s
  1800K .......... .......... .......... .......... .......... 85% 61.4M 0s
  1850K .......... .......... .......... .......... .......... 88% 56.1M 0s
  1900K .......... .......... .......... .......... .......... 90% 10.6M 0s
  1950K .......... .......... .......... .......... .......... 92% 13.5M 0s
  2000K .......... .......... .......... .......... .......... 95% 7.90M 0s
  2050K .......... .......... .......... .......... .......... 97% 30.2M 0s
  2100K .......... .......... .......... .......... .......... 99% 13.3M 0s
  2150K ....                                                  100% 35.6M=0.3s

2024-09-12 10:19:12 (8.06 MB/s) - 'geocolor.png' saved [2206382/2206382]

--2024-09-12 10:19:12--  http://rfd.atmos.uiuc.edu/305/Hurr_Franklin/WV.png
Resolving rfd.atmos.uiuc.edu (rfd.atmos.uiuc.edu)... 192.17.107.225
Connecting to rfd.atmos.uiuc.edu (rfd.atmos.uiuc.edu)|192.17.107.225|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2273745 (2.2M) [image/png]
Saving to: 'vapor.png'

     0K .......... .......... .......... .......... ..........  2%  768K 3s
    50K .......... .......... .......... .......... ..........  4% 2.11M 2s
   100K .......... .......... .......... .......... ..........  6% 8.14M 1s
   150K .......... .......... .......... .......... ..........  9% 2.64M 1s
   200K .......... .......... .......... .......... .......... 11% 20.1M 1s
   250K .......... .......... .......... .......... .......... 13% 4.86M 1s
   300K .......... .......... .......... .......... .......... 15% 4.31M 1s
   350K .......... .......... .......... .......... .......... 18% 21.5M 1s
   400K .......... .......... .......... .......... .......... 20% 11.6M 1s
   450K .......... .......... .......... .......... .......... 22% 16.3M 1s
   500K .......... .......... .......... .......... .......... 24% 4.53M 0s
   550K .......... .......... .......... .......... .......... 27% 9.94M 0s
   600K .......... .......... .......... .......... .......... 29% 15.1M 0s
   650K .......... .......... .......... .......... .......... 31% 29.5M 0s
   700K .......... .......... .......... .......... .......... 33% 13.6M 0s
   750K .......... .......... .......... .......... .......... 36% 8.10M 0s
   800K .......... .......... .......... .......... .......... 38% 9.21M 0s
   850K .......... .......... .......... .......... .......... 40% 9.96M 0s
   900K .......... .......... .......... .......... .......... 42% 29.0M 0s
   950K .......... .......... .......... .......... .......... 45% 11.1M 0s
  1000K .......... .......... .......... .......... .......... 47% 18.4M 0s
  1050K .......... .......... .......... .......... .......... 49%  182M 0s
  1100K .......... .......... .......... .......... .......... 51% 7.56M 0s
  1150K .......... .......... .......... .......... .......... 54% 11.4M 0s
  1200K .......... .......... .......... .......... .......... 56% 13.1M 0s
  1250K .......... .......... .......... .......... .......... 58% 30.0M 0s
  1300K .......... .......... .......... .......... .......... 60% 17.0M 0s
  1350K .......... .......... .......... .......... .......... 63% 36.2M 0s
  1400K .......... .......... .......... .......... .......... 65% 46.9M 0s
  1450K .......... .......... .......... .......... .......... 67% 11.7M 0s
  1500K .......... .......... .......... .......... .......... 69% 9.12M 0s
  1550K .......... .......... .......... .......... .......... 72% 15.9M 0s
  1600K .......... .......... .......... .......... .......... 74% 23.6M 0s
  1650K .......... .......... .......... .......... .......... 76% 9.73M 0s
  1700K .......... .......... .......... .......... .......... 78% 36.2M 0s
  1750K .......... .......... .......... .......... .......... 81% 40.7M 0s
  1800K .......... .......... .......... .......... .......... 83% 42.6M 0s
  1850K .......... .......... .......... .......... .......... 85% 56.3M 0s
  1900K .......... .......... .......... .......... .......... 87% 14.0M 0s
  1950K .......... .......... .......... .......... .......... 90% 10.9M 0s
  2000K .......... .......... .......... .......... .......... 92% 34.2M 0s
  2050K .......... .......... .......... .......... .......... 94% 9.31M 0s
  2100K .......... .......... .......... .......... .......... 96% 37.6M 0s
  2150K .......... .......... .......... .......... .......... 99% 12.6M 0s
  2200K .......... ..........                                 100% 26.7M=0.3s

2024-09-12 10:19:13 (8.29 MB/s) - 'vapor.png' saved [2273745/2273745]

--2024-09-12 10:19:13--  http://rfd.atmos.uiuc.edu/305/Hurr_Franklin/CO2.png
Resolving rfd.atmos.uiuc.edu (rfd.atmos.uiuc.edu)... 192.17.107.225
Connecting to rfd.atmos.uiuc.edu (rfd.atmos.uiuc.edu)|192.17.107.225|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2450963 (2.3M) [image/png]
Saving to: 'CO2.png'

     0K .......... .......... .......... .......... ..........  2%  894K 3s
    50K .......... .......... .......... .......... ..........  4% 2.22M 2s
   100K .......... .......... .......... .......... ..........  6% 9.21M 1s
   150K .......... .......... .......... .......... ..........  8% 8.71M 1s
   200K .......... .......... .......... .......... .......... 10% 4.53M 1s
   250K .......... .......... .......... .......... .......... 12% 11.3M 1s
   300K .......... .......... .......... .......... .......... 14% 7.87M 1s
   350K .......... .......... .......... .......... .......... 16% 5.36M 1s
   400K .......... .......... .......... .......... .......... 18% 10.2M 1s
   450K .......... .......... .......... .......... .......... 20% 12.3M 0s
   500K .......... .......... .......... .......... .......... 22% 23.3M 0s
   550K .......... .......... .......... .......... .......... 25% 8.02M 0s
   600K .......... .......... .......... .......... .......... 27% 10.1M 0s
   650K .......... .......... .......... .......... .......... 29% 27.7M 0s
   700K .......... .......... .......... .......... .......... 31% 10.1M 0s
   750K .......... .......... .......... .......... .......... 33% 6.65M 0s
   800K .......... .......... .......... .......... .......... 35% 28.3M 0s
   850K .......... .......... .......... .......... .......... 37% 13.9M 0s
   900K .......... .......... .......... .......... .......... 39% 24.7M 0s
   950K .......... .......... .......... .......... .......... 41% 13.1M 0s
  1000K .......... .......... .......... .......... .......... 43% 30.0M 0s
  1050K .......... .......... .......... .......... .......... 45% 6.41M 0s
  1100K .......... .......... .......... .......... .......... 48% 34.8M 0s
  1150K .......... .......... .......... .......... .......... 50% 15.7M 0s
  1200K .......... .......... .......... .......... .......... 52% 29.3M 0s
  1250K .......... .......... .......... .......... .......... 54% 36.0M 0s
  1300K .......... .......... .......... .......... .......... 56% 14.6M 0s
  1350K .......... .......... .......... .......... .......... 58% 31.4M 0s
  1400K .......... .......... .......... .......... .......... 60% 6.69M 0s
  1450K .......... .......... .......... .......... .......... 62% 25.3M 0s
  1500K .......... .......... .......... .......... .......... 64% 26.8M 0s
  1550K .......... .......... .......... .......... .......... 66% 31.3M 0s
  1600K .......... .......... .......... .......... .......... 68% 48.7M 0s
  1650K .......... .......... .......... .......... .......... 71% 17.2M 0s
  1700K .......... .......... .......... .......... .......... 73% 30.2M 0s
  1750K .......... .......... .......... .......... .......... 75% 39.6M 0s
  1800K .......... .......... .......... .......... .......... 77% 7.11M 0s
  1850K .......... .......... .......... .......... .......... 79% 32.3M 0s
  1900K .......... .......... .......... .......... .......... 81% 38.4M 0s
  1950K .......... .......... .......... .......... .......... 83% 15.0M 0s
  2000K .......... .......... .......... .......... .......... 85% 25.1M 0s
  2050K .......... .......... .......... .......... .......... 87% 39.7M 0s
  2100K .......... .......... .......... .......... .......... 89% 64.0M 0s
  2150K .......... .......... .......... .......... .......... 91% 70.7M 0s
  2200K .......... .......... .......... .......... .......... 94% 66.1M 0s
  2250K .......... .......... .......... .......... .......... 96% 7.01M 0s
  2300K .......... .......... .......... .......... .......... 98% 16.4M 0s
  2350K .......... .......... .......... .......... ...       100% 33.3M=0.2s

2024-09-12 10:19:13 (9.89 MB/s) - 'CO2.png' saved [2450963/2450963]

In [4]:
# >>> C. DISPLAY 4 IMAGES
# Use dpi=200, and subplot() for a 1-row 4-column arrangement.
# For each image:
#    a) Do plt.subplot( Max-X-dimension, Max-Y-dimension, Plot-panel-number)
#        (in this case, they will all be: subplot(1,4,[1,2,3 or 4]);
#    b) Display the image, e.g. plt.imshow(name-of-image-variable)
#    c) Add a title, i.e. plt.title('some name that makes sense e.g. Geocolor');
#    d) And .. suppress the tick marks with plt.xticks([]); do yticks similarly.
# More on ticks:
#    www.geeksforgeeks.org/how-to-hide-axis-text-ticks-or-tick-labels-in-matplotlib

ir = mpimg.imread('infrared.png')
geo = mpimg.imread('geocolor.png')
vapor = mpimg.imread('vapor.png')
co2 = mpimg.imread('CO2.png')

plt.figure(figsize=(10, 5), dpi=200)

plt.subplot(1, 4, 1)
plt.imshow(ir)
plt.title('Infrared')
plt.xticks([])
plt.yticks([])

plt.subplot(1, 4, 2)
plt.imshow(geo)
plt.title('Geocolor')
plt.xticks([])
plt.yticks([])

plt.subplot(1, 4, 3)
plt.imshow(vapor)
plt.title('Vapor')
plt.xticks([])
plt.yticks([])

plt.subplot(1, 4, 4)
plt.imshow(co2)
plt.title('CO2')
plt.xticks([])
plt.yticks([])

plt.tight_layout()
plt.show()
No description has been provided for this image
In [5]:
# >>> D. DISPLAY Infrared in COLOR
# Show the IR image separately with dpi=200.
# This is a color image contained in array IR
#   ... and IR contains red, green and blue channels (RGB)
# Add title: IR image of Hurricane Franklin

plt.figure(figsize=(5, 5), dpi=200)
plt.imshow(ir)
plt.title('IR Image of Hurricane Franklin')
plt.xticks([])
plt.yticks([])

plt.tight_layout()
plt.show()
No description has been provided for this image
In [6]:
# >>> E. Display RED CHANNEL of the infrared (IR) IMAGE
# 1. Copy the red part of image IR to variable "red" like this:
#                 red = IR[:, :, 0]
#     IR[:,:,0] means all rows (first :), all columns, color index 0 (red)
# 2. Start a new figure with dpi=200
# 3. Display the "red" image (2-D !!) with imshow, adding option:  ,cmap='Greys'
# 4. Add a colorbar with: plt.colorbar()
# 5. Add title: Franklin IR, Red channel
# 6. Add xlabel: Columns
# 7. Add ylabel: Rows
#
# The red part of the image is what stands out in full color (see above).
# It stands out as the highest (most) red intensity when viewing just the red channel
#  here (or, the lowest value of the blue channel - take a look if you wish).

red = ir[:, :, 0]

plt.figure(figsize=(5, 5), dpi=200)
plt.imshow(red, cmap='Greys')
plt.colorbar()
plt.title('Franklin IR, Red Channel')

plt.xlabel('Columns')
plt.ylabel('Rows')

plt.tight_layout()
plt.show()
No description has been provided for this image
In [7]:
# >>> F. HISTOGRAM of the RED image
# 1. Start a new 10x6" figure like this:
#           plt.figure( figsize=(10,6) )
# 2. Convert "red" to 1-D using numpy's "reshape"; call the result "red1D"
#      ... because "reshape" is part of numpy, we call it: np.reshape()
#      ... np.reshape expects two "arguments" : the array name, and size
#      ... so call it like THIS:  red1D = np.reshape(red, red.size);
# 3. Plot a histogram of "red1D" using np.hist() with 20 bins
#      ... hist() is part of numpy, too, so we call it: np.hist()
#      ... np.hist expects to arguments : the 1-D array name, and number of bins.
#      ... so you give np.hist():  red1D, followed by: bins=20
# 4. Add title:  Histogram of red IR channel
# 5. Add x label: red IR bin values
# 6. Add y label: number of grid cells
#
# Histograms show how OFTEN the data values occur.  They
# are computed with "bins" each with a range of values, for
# which the Y axis shows how often that range was found.
# This histogram shows a Lot of white (low) values, and
# many less occurrences of higher values (dark, in image above),
# but there is a peak in high (dark = very red!) values in the eye.

plt.figure(figsize=(10, 6))

red1D = np.reshape(red, red.size)

plt.hist(red1D, bins=20)
plt.title('Histogram of Red IR Channel')
plt.xlabel('Red IR Bin Values')
plt.ylabel('Number of Grid Cells')
plt.tight_layout()
plt.show()
No description has been provided for this image
In [8]:
# USE THIS cell to SAVE NOTEBOOK as HTML
# 1. LEAVE this cell COMMENTED OUT until your code works.
# 2. Still with this commented out, save notebook.ipynb file to your PC.
# 3. Upload the .ipynb file from your PC to Colab space
# 4. NOW uncomment this cell
# 5. Change filename below (after "--to html") to this notebook's name
# 6. Run JUST this cell.
# 7. Find the new .html file; Refresh the Colab file list if need be
# 8. Save (from 3-dots) the .html file to your PC.
# 9. Upload both the .ipynb and the .html files to MOODLE.
# %%shell
# jupyter nbconvert --to html  Lab03_HurrFranklin.ipynb
In [ ]: